import type { App } from "vue";
import { useUserInfo } from "@/stores/userInfo";
import { storeToRefs } from "pinia";

export function authDirective(app:App){
    // v-auth="'sys:user:add'"
    app.directive('auth',{
        mounted(el,binding){
            const userInfoStore = useUserInfo();
            const {state} = storeToRefs(userInfoStore);
            const {value} = binding
            if(!state.value.userInfos.authBtnList.includes(value)){
                el.parentNode.removeChild(el);
            }
        }
    })
}